import React, { PureComponent, Component } from 'react';
import moment from 'moment'
import {
    View,
    Text,
    StyleSheet,
    TouchableOpacity
} from 'react-native'
import WXStyle from '../utils/style/wxstyle';
import Style from '../utils/style/style';
export default class PurchaseItem extends PureComponent {
    constructor(props) {
        super(props)
    }

    render() {
        const { item } = this.props;
        const time = moment(item.PurchaseTime).format('YYYY-MM-DD');
        return (
            <TouchableOpacity onPress={this.props.pressItem} style={styles.item}>
                <View style={[Style.dfr, Style.aic, styles.box]}>
                    <View style={[Style.flex1, Style.jssb]}>
                        <View style={[Style.dfr, Style.aic, Style.jsfs]}>
                            <View>
                                <Text style={[Style.f17, Style.colorBlack]}>{item.Code}</Text>
                            </View>
                            <View style={Style.ml5}>
                                <Text style={[Style.f12, item.state == 1 ? Style.colorGreen : item.state == 2 ? Style.colorWarining : Style.colorError]}>[{item.state == 1 ? '已入库' : item.state == 2 ? '部分入库' : '待入库'}]</Text>
                            </View>
                        </View>
                        <View >
                            <Text>
                                共采购商品：{item.species}种，{item.PNumber}件
                            </Text>
                        </View>
                        <View >
                            <Text>
                                采购时间：{time}
                            </Text>
                        </View>
                    </View>
                    <View style={[styles.totalPrice, Style.aic, Style.jsfe]}>
                        <View >
                            <Text style={[styles.icon]}> ￥{item.TotalPrice / 100}</Text>
                        </View>
                    </View>
                </View>
            </TouchableOpacity >

        )
    }
}
const styles = StyleSheet.create({
    item: {
        height: 81,
        width: Style.width,
        backgroundColor: '#fff',
    },
    box: {
        borderStyle: 'solid',
        borderColor: '#e5e5e5',
        borderBottomWidth: 1,
        marginLeft: 10,
        paddingTop: 10,
        paddingBottom: 10,
    },
    totalPrice: {
        margin: 0,
        width: 110,

    },
    icon: {
        color: WXStyle.mainColor,
        fontSize: 18,
        marginRight: 10
    }
})